package dao.impl;

import dao.UserDao;
import entity.User;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanHandler;
import util.DbUtils;

import java.sql.SQLException;

/**
 * User: key
 * ClassName:UserDaoImpl
 * Date: 2023/5/5
 * Time: 18:49
 * description:
 */
public class UserDaoImpl implements UserDao {
    private QueryRunner qr = new QueryRunner(DbUtils.getDataSource());
    @Override
    public User findUserByUsername(String name) throws SQLException {
        return qr.query("select * from user where name = ?",
                new BeanHandler<>(User.class),name);
    }
}
